import translations from './lang/zh'

export default function customTranslate(template, replacements) {
    replacements = replacements || {}

    template = translations[template] || template

    return template.replace(/{([^}]+)}/g, (_info_, key) => {
        let str = replacements[key]

        if (translations[replacements[key]] !== null && translations[replacements[key]] !== 'undefined') {
            str = translations[replacements[key]]
        }
        return str || `{${key}}`
    })
}
